package com.ruoyi.tongban.facedetect.utils;

import com.ruoyi.tongban.facedetect.domain.WebSocketSessionBody;

import java.util.Collection;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * session缓存
 */
public class SessionCacheBody {

    private static Map<String, WebSocketSessionBody> sessionMap = new ConcurrentHashMap<String, WebSocketSessionBody>();

    public static WebSocketSessionBody getSession(String sn) {
        return sessionMap.get(sn);
    }

    public static void setSession(String sn, WebSocketSessionBody webSocketSession){
        sessionMap.put(sn, webSocketSession);
    }

    public static Collection getAllSession(){
        return sessionMap.values();
    }

    public static void removeSession(String sn){
        sessionMap.remove(sn);
    }

}
